home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Graphics Unleashed
/
PC Graphics Unleashed.iso
/
ch18
/
rtrace
/
mol2scn.awk
< prev
next >
Wrap
Text File
|
1993-07-05
|
2KB
|
62 lines
BEGIN {
FS = " "
getline
getline
}
/atoms/ {
print "% Converted to SCN"
print "% Copyright 1992 Antonio Costa (acc@asterix.inescn.pt)"
printf "\n#include \"mol.h\"\n\n"
print "% Atoms:", $1, "- Bonds:", $3
atoms = $1
t++
maxx = -10000
maxy = -10000
maxz = -10000
minx = -maxx
miny = -maxy
minz = -maxz
next
}
/^[^0-9]/ {
c[$1] = $4
if ($6 == 0) r[$1] = 0.1
if ($6 != 0) r[$1] = $6
next
}
/^[0-9]+[ \t]+[^0-9]/ {
printf "sphere surface matte %s data %g %g %g %g\n", \
c[$2], $3, $4, $5, r[$2]
if ($3 > maxx) maxx = $3
if ($4 > maxy) maxy = $4
if ($5 > maxz) maxz = $5
if ($3 < minx) minx = $3
if ($4 < miny) miny = $4
if ($5 < minz) minz = $5
atoms--
if (atoms == 0) exit
next
}
END {
if (maxx < maxy && maxx < maxz) {
printf "\neye %g %g %g\n", \
maxx + 3 * (maxx - minx), maxy, maxz
printf "light point %g %g %g white\n", \
maxx + 2 * (maxx - minx), maxy, maxz
}
if (maxy < maxx && maxy < maxz) {
printf "\neye %g %g %g\n", \
maxx, maxy + 3 * (maxy - miny), maxz
printf "light point %g %g %g white\n", \
maxx, maxy + 2 * (maxy - miny), maxz
}
if (maxz < maxx && maxz < maxy) {
printf "\neye %g %g %g\n", \
maxx, maxy, maxz + 3 * (maxz - minz)
printf "light point %g %g %g white\n", \
maxx, maxy, maxz + 2 * (maxz - minz)
}
printf "at %g %g %g\n", \
(maxx + minx) / 2.0, (maxy + miny) / 2.0, (maxz + minz) / 2.0
}